package com.neuedu.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.neuedu.pojo.Result;
import com.neuedu.pojo.TElder;
import com.neuedu.pojo.THealth;
import com.neuedu.mapper.THealthMapper;
import com.neuedu.service.ITHealthService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zhangsan
 * @since 2024-06-17
 */
@Service
public class THealthServiceImpl extends ServiceImpl<THealthMapper, THealth> implements ITHealthService {
    @Autowired
     THealthMapper healthMapper;

    @Override
    public Result findByeldId(long elderId) {
        LambdaQueryWrapper<THealth> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(THealth::getEldId,elderId);
        THealth health=healthMapper.selectOne(wrapper);
        return Result.success(health,"查询成功");
    }

    @Override
    public Result moHealth(THealth health) {
        health.setUpdateTime(LocalDateTime.now());
        return Result.success(healthMapper.updateById(health),"修改成功");
    }

    @Override
    public Result addHealth(THealth health) {
        health.setCreateTime(LocalDateTime.now());
        health.setUpdateTime(LocalDateTime.now());
        return Result.success(healthMapper.insert(health),"修改成功");
    }
}
